import { useEffect, useState } from 'react'
import axios from '../../../utils/index'
import PropTypes from 'prop-types'
import Person from './Person'
Message.propTypes = {
    // userid
    userid: PropTypes.string.isRequired,
}

export default function Message(props) {
    let [frinend, setFinend] = useState([]);
    // function setNewFinend() {

    // }
    useEffect(() => {
        axios.get(`/getconversation/${props.userid}`).then(res => {
            setFinend(res.data)
        })
    }, [props.userid])
    return (
        <div>
            {frinend?.map(item => {
                return <Person key={item._id} personId={item.members.filter(i => i != props.userid)} id={item._id} />;
            })}
        </div>
    )
}
